package game;

import factory.FileGameConfigurator;
import factory.GameConfigurator;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

public class GameDriver
{
	public GameDriver()
	{
		itsGameConfigurator = new FileGameConfigurator();
		itsGames = new LinkedList<Game>();
	}
	
	public void run()
	{
		itsGameConfigurator.createGames(this);
		playGames();
	}
	
	private void playGames()
	{
		int i = 1;
		Iterator<Game> iter = itsGames.iterator();
		while(iter.hasNext())
		{
			System.out.println("\ngame #" + i++);
			Game game = iter.next();
			game.play();
		}
	}
	
	public void addGame(Game game)
	{
		itsGames.add(game);
	}
	
	
	GameConfigurator itsGameConfigurator;
	List<Game> itsGames;
}
